<?php
/**
 * 抽象工厂模式
 */

interface TV
{
    public function open();
    public function watch();
}

class HaierTV implements TV
{
    public function open()
    {
        echo "open HaierTv";
    }
    
    public function watch()
    {
        echo "watch HaierTv";
    }
}
class LenovoTV implements TV
{
    public function open()
    {
        echo "open lenovoTv";
    }
    public function watch()
    {
        echo "watch lenovoTv";
    }
}

interface PC
{
    public function work();
    public function play();
}

class LenovoPC implements PC
{
    public function work()
    {
        echo "lenovopc work";
    }
    public function play()
    {
        echo "lenovopc play";
    }
}
class HaierPC implements PC
{
    public function work()
    {
        echo "haierpc work";
    }
    public function play()
    {
        echo "haierpc play";
    }
}

abstract class Factory
{
    abstract public static function  createPC();
    abstract public static function createTV();
}

class HaierFactory extends Factory
{
    public static function createPC()
    {
        return new HaierPC();
    }
    
    public static function createTV()
    {
        return new HaierTV();
    }
}

class LenovoFactory extends Factory
{
    public static function createPC()
    {
        return new LenovoPC();
    }
    public static function createTV()
    {
        return new LenovoTV();
    }
}

